Skip to content

[#560] Improve trending algorithm — recency boost, Bayesian ratings, default sort#561

Merged
realproject7 merged 2 commits intomainfrom
task/560-trending-algorithm
Mar 26, 2026
Merged

[#560] Improve trending algorithm — recency boost, Bayesian ratings, default sort#561
realproject7 merged 2 commits intomainfrom
task/560-trending-algorithm

Conversation

@realproject7
Copy link
Copy Markdown
Owner

Summary

  • Recency signal (20% weight): Uses last_plot_time with inverse-time decay (1 / (1 + daysSince)) so recently updated stories rank higher than stale ones.
  • Bayesian weighted rating (25% weight): Replaces raw average with (count × avg + 5 × 3.0) / (count + 5) — a story with 1 rating of 5.0 now scores 3.33 instead of 5.0, while 20 ratings of 4.5 scores 4.20.
  • Default sort changed to trending: Homepage now defaults to the trending tab instead of new.
  • Rebalanced weights: Rating 25%, Price 20%, TVL 20%, Continuation 15%, Recency 20%.

Files Changed

  • lib/ranking.tscomputeTrendScore() updated with 5th signal + Bayesian rating; fetchCandidatesAndRatings() now returns rating counts
  • src/app/page.tsx — default tab changed from "new" to "trending"

Test plan

  • Verify trending tab loads on plotlink.xyz homepage by default
  • Confirm recently updated stories appear higher in trending
  • Confirm stories with few ratings don't dominate over well-rated stories
  • Verify ?tab=new still works as before

Fixes #560

🤖 Generated with Claude Code

- Add recency signal (20% weight) using last_plot_time with inverse-time
  decay so recently updated stories rank higher
- Replace raw average rating with Bayesian weighted rating
  (prior_count=5, prior_mean=3.0) so stories need multiple good ratings
  to rank high
- Redistribute weights: rating 25%, price 20%, TVL 20%, continuation 15%,
  recency 20%
- Change default homepage sort tab from "new" to "trending"

Fixes #560

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
plotlink Ignored Ignored Mar 26, 2026 11:59am

Request Review

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

T2b APPROVE. Bayesian rating formula is correct (prior_count=5, prior_mean=3.0). Weights sum to 1.00. Recency decay is clean with proper null fallback to createdAt. ratingMap refactor is well-structured. Default sort change is straightforward. No issues found.

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: REQUEST CHANGES

Summary

The Bayesian weighting and default-tab change are reasonable, but the recency requirement is still not implemented end-to-end.

Findings

  • [high] The new recency signal only reorders the newest 50 stories by creation time, because the candidate query still sorts by block_timestamp and truncates before scoring. Older stories with a fresh last_plot_time never enter the candidate set, so they cannot receive the intended recency boost.
    • File: lib/ranking.ts:95
    • Suggestion: Build the candidate set from last_plot_time or widen the pre-score window enough that recently updated older stories remain eligible before the final ranking pass.

Decision

Requesting changes because queue #560 explicitly requires trending to favor recently updated stories, and the current candidate selection still filters those stories out before the new signal is applied.

Fetch two pools (newest by creation + recently active by last_plot_time)
and merge/deduplicate, so older stories with fresh plot activity are
eligible for the recency boost instead of being cut off by the
block_timestamp ordering.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE

Summary

The recency signal is now wired through the candidate-selection stage instead of only the final scoring stage.

Findings

  • None.

Decision

Approving because the updated lib/ranking.ts now merges newest-by-creation and newest-by-activity candidate pools before scoring, so older stories with fresh last_plot_time updates are eligible for the recency boost, and the PR still satisfies the Bayesian-rating and default-tab requirements.

@realproject7 realproject7 merged commit 8dfbc3f into main Mar 26, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve trending algorithm — recency boost, weighted ratings, make default

2 participants